import type {
  GetCodeData,
  GetCodeParams,
  LoginCodeData,
  LoginCodeParams,
  LoginPswParams,
  UserData,
} from '@/types/user'
import { http } from '@/utils/http'

/**
 * 发送验证码
 */
export const getCodeApi = (params: GetCodeParams) => {
  // get 方法的参数需要通过 params 来传递
  return http.get<null, GetCodeData>('/code', { params })
}
// 手机验证码接口
export const loginByMobileApi = (params: LoginCodeParams) => {
  return http.post<LoginCodeData, LoginCodeParams>('/login', params)
}
// 密码登录接口
export const loginByPswApi = (params: LoginPswParams) => {
  return http.post<LoginCodeData, LoginPswParams>('/login/password', params)
}

// 获取用户信息
export const userInfoApi = () => {
  return http.get<null, UserData>('/patient/myUser')
}
